package testdemo;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.apache.log4j.PropertyConfigurator;
import org.junit.Test;
import tools.get;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.UndeclaredThrowableException;
import java.util.List;
import java.util.Properties;

public class TestMybatis1 {
    public static void main(String[] args) throws IOException {
        //输出查询过程日志
        get.Get();
        SqlSession sqlSession = get.getsqlSession();
        //4.执行映射文件中的sql语句
        List<Object> objects = sqlSession.selectList("EmpMapper.FindAlldate");
        for (Object obj : objects) {
            System.out.println(obj);
        }
    }
///删除数据库列表
    public void delData() throws IOException {
        //输出查询过程日志
        get.Get();
        SqlSession sqlSession = get.getsqlSession();
        int update=sqlSession.update("EmpMapper.deletedata");
        //提交事务
        sqlSession.commit();
        System.out.println("update="+update);
    }
    //添加数据库信息
    public void insert() throws IOException {
        //输出查询过程日志
        get.Get();
        SqlSession sqlSession = get.getsqlSession();
        int insert = sqlSession.insert("EmpMapper.insertdata");
        //提交事务
        sqlSession.commit();
        System.out.println("insert="+insert);
    }

    public void updata()throws IOException {
        //输出查询过程日志
        get.Get();
        SqlSession sqlSession = get.getsqlSession();
        int update = sqlSession.update("EmpMapper.updata");
        //提交事务
        sqlSession.commit();

    }
}
